package com.github.permissiondog.cancanpandroid.ui.view;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;

import com.github.permissiondog.cancanpandroid.R;
import com.github.permissiondog.cancanpandroid.databinding.ActivityApplicantMainBinding;

public class ApplicantMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityApplicantMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_applicant_main);
        binding.bnvApplicantMain.setOnItemSelectedListener(item -> {
            var fragment = switch (item.getItemId()) {
                case R.id.application_fragment -> ApplicationFragment.newInstance();
                case R.id.settings_fragment -> new SettingsFragment();
                default -> throw new IllegalStateException("Unexpected value: " + item.getItemId());
            };

            getSupportFragmentManager().beginTransaction().replace(R.id.fl_applicant_main, fragment).commit();
            return true;
        });
        binding.bnvApplicantMain.setSelectedItemId(R.id.application_fragment);
    }
}